Overview | Package | Class | Tree | Deprecated | Index | Help |
Java Platform 1.1.7 |
||
PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.sun.java.swing.text.View
Field Summary | |
static int | BadBreakWeight
The weight to indicate a view is a bad break opportunity for the purpose of formatting. |
static int | ExcellentBreakWeight
The weight to indicate a view supports breaking, and this represents a very attractive place to break. |
static int | ForcedBreakWeight
The weight to indicate a view supports breaking, and must be broken to be represented properly when placed in a view that formats it's children by breaking them. |
static int | GoodBreakWeight
The weight to indicate a view supports breaking, but better opportunities probably exist. |
static int | X_AXIS
Axis for format/break operations. |
static int | Y_AXIS
Axis for format/break operations. |
Constructor Summary | |
View(Element elem)
Creates a new View object. |
Method Summary | |
View | breakView(int axis,
int offset,
float pos,
float len)
Tries to break this view on the given axis. |
void | changedUpdate(DocumentEvent e,
java.awt.Shape a,
ViewFactory f)
Gives notification from the document that attributes were changed in a location that this view is responsible for. |
View | createFragment(int p0,
int p1)
Create a view that represents a portion of the element. |
float | getAlignment(int axis)
Determines the desired alignment for this view along an axis. |
int | getBreakWeight(int axis,
float pos,
float len)
Determines how attractive a break opportunity in this view is. |
java.awt.Shape | getChildAllocation(int index,
java.awt.Shape a)
Fetches the allocation for the given child view. |
java.awt.Container | getContainer()
Fetches the container hosting the view. |
Document | getDocument()
Fetches the model associated with the view. |
Element | getElement()
Fetches the structural portion of the subject that this view is mapped to. |
int | getEndOffset()
Fetches the portion of the model that this view is responsible for. |
View | getParent()
Returns the parent of the view. |
float | getPreferredSpan(int axis)
Determines the preferred span for this view along an axis. |
int | getResizeWeight(int axis)
Determines the resizability of the view along the given axis. |
int | getStartOffset()
Fetches the portion of the model that this view is responsible for. |
int | getViewCount()
Returns the number of views in this view. |
ViewFactory | getViewFactory()
Fetches the ViewFactory implementation that is feeding the view hierarchy. |
View | getView(int n)
Gets the nth child view. |
void | insertUpdate(DocumentEvent e,
java.awt.Shape a,
ViewFactory f)
Gives notification that something was inserted into the document in a location that this view is responsible for. |
java.awt.Shape | modelToView(int pos,
java.awt.Shape a)
Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it. |
void | paint(java.awt.Graphics g,
java.awt.Shape allocation)
Renders using the given rendering surface and area on that surface. |
void | preferenceChanged(View child,
boolean width,
boolean height)
Child views can call this on the parent to indicate that the preference has changed and should be reconsidered for layout. |
void | removeUpdate(DocumentEvent e,
java.awt.Shape a,
ViewFactory f)
Gives notification from the document that attributes were removed in a location that this view is responsible for. |
void | setParent(View parent)
Establishes the parent view for this view. |
void | setSize(float width,
float height)
Sets the size of the view. |
int | viewToModel(float x,
float y,
java.awt.Shape a)
Provides a mapping from the view coordinate space to the logical coordinate space of the model. |
Methods inherited from class java.lang.Object | |
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait |
Field Detail |
public static final int BadBreakWeight
public static final int GoodBreakWeight
public static final int ExcellentBreakWeight
public static final int ForcedBreakWeight
public static final int X_AXIS
public static final int Y_AXIS
Constructor Detail |
public View(Element elem)
elem
- the element to representMethod Detail |
protected final View getParent()
public abstract float getPreferredSpan(int axis)
axis
- may be either View.X_AXIS or View.Y_AXISpublic void preferenceChanged(View child, boolean width, boolean height)
revalidate
on the associated text component.
child
- the child view
width
- true if the width preference has changed
height
- true if the height preference has changedpublic float getAlignment(int axis)
axis
- may be either View.X_AXIS or View.Y_AXISpublic abstract void paint(java.awt.Graphics g, java.awt.Shape allocation)
g
- the rendering surface to use
allocation
- the allocated region to render intopublic void setParent(View parent)
super.setParent()
should be called.
parent
- the new parent, or null if the view is
being removed from a parent it was previously added
topublic int getViewCount()
public View getView(int n)
n
- the number of the view to get, >= 0 && < getViewCount()public java.awt.Shape getChildAllocation(int index, java.awt.Shape a)
index
- the index of the child, >= 0 && < getViewCount()
a
- the allocation to this view.public abstract java.awt.Shape modelToView(int pos, java.awt.Shape a) throws BadLocationException
pos
- the position to convert >= 0
a
- the allocated region to render intopublic abstract int viewToModel(float x, float y, java.awt.Shape a)
x
- the X coordinate >= 0
y
- the Y coordinate >= 0
a
- the allocated region to render intopublic void insertUpdate(DocumentEvent e, java.awt.Shape a, ViewFactory f)
e
- the change information from the associated document
a
- the current allocation of the view
f
- the factory to use to rebuild if the view has childrenpublic void removeUpdate(DocumentEvent e, java.awt.Shape a, ViewFactory f)
e
- the change information from the associated document
a
- the current allocation of the view
f
- the factory to use to rebuild if the view has childrenpublic void changedUpdate(DocumentEvent e, java.awt.Shape a, ViewFactory f)
e
- the change information from the associated document
a
- the current allocation of the view
f
- the factory to use to rebuild if the view has childrenpublic Document getDocument()
public int getStartOffset()
public int getEndOffset()
public Element getElement()
public View breakView(int axis, int offset, float pos, float len)
This is implemented to return the view itself, which represents the default behavior on not being breakable. If the view does support breaking, the starting offset of the view returned should be the given offset, and the end offset should be less than or equal to the end offset of the view being broken.
axis
- may be either View.X_AXIS or View.Y_AXIS
offset
- the location in the document model
that a broken fragment would occupy >= 0. This
would be the starting offset of the fragment
returned.
pos
- the position along the axis that the
broken view would occupy >= 0. This may be useful for
things like tab calculations.
len
- specifies the distance along the axis
where a potential break is desired >= 0.public View createFragment(int p0, int p1)
p0
- the starting offset >= 0. This should be a value
greater or equal to the element starting offset and
less than the element ending offset.
p1
- the ending offset > p0. This should be a value
less than or equal to the elements end offset and
greater than the elements starting offset.public int getBreakWeight(int axis, float pos, float len)
breakView
on in the process of formatting. A view that represents
text that has whitespace in it might be more attractive
than a view that has no whitespace, for example. The
higher the weight, the more attractive the break. A
value equal to or lower than BadBreakWeight
should not be considered for a break. A value greater
than or equal to ForcedBreakWeight
should
be broken.
This is implemented to provide the default behavior
of returning BadBreakWeight
unless the length
is greater than the length of the view in which case the
entire view represents the fragment. Unless a view has
been written to support breaking behavior, it is not
attractive to try and break the view. An example of
a view that does support breaking is LabelView
.
An example of a view that uses break weight is
ParagraphView
.
axis
- may be either View.X_AXIS or View.Y_AXIS
pos
- the potential location of the start of the
broken view >= 0. This may be useful for calculating tab
positions.
len
- specifies the relative length from pos
where a potential break is desired >= 0.public int getResizeWeight(int axis)
axis
- View.X_AXIS or View.Y_AXISpublic void setSize(float width, float height)
width
- the width >= 0
height
- the height >= 0public java.awt.Container getContainer()
public ViewFactory getViewFactory()
Overview | Package | Class | Tree | Deprecated | Index | Help |
Java Platform 1.1.7 |
||
PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |